package com.travel.photos.ui.find;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.travel.R;
import com.travel.photos.bean.FindDataListBean;
import com.travel.photos.image.ImageHepler;
import com.travel.photos.ui.otheruser.OtherUserActivity;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import tools.AdapterUtils;

/**
 * Created by meidou on 2016/10/18.
 * find中点赞
 */
public class GoodAdapter extends AdapterUtils<FindDataListBean.ChBean> {
    public GoodAdapter(Context mcontext, List<FindDataListBean.ChBean> totalList) {
        super(mcontext, totalList);
    }

    @Override
    public View getMyView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            convertView = mInflater.inflate(R.layout.item_photo_find_gridview, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        ImageHepler.showImage(mcontext,totalList.get(position).getMemImg(),viewHolder.mPhotoFindItemGridImage,true);
        viewHolder.mPhotoFindItemGridImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mcontext, OtherUserActivity.class);
                intent.putExtra("userId",totalList.get(position).getId());
                intent.putExtra("name",totalList.get(position).getName());
                intent.putExtra("image",totalList.get(position).getMemImg());
                mcontext.startActivity(intent);
            }
        });
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.photo_find_item_grid_image)
        ImageView mPhotoFindItemGridImage;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
